import { prisma } from "@/lib/prisma"
import { getServerSession } from "next-auth"
import { NextResponse } from "next/server"

export async function GET() {
  try {
    const session = await getServerSession()
    
    if (!session) {
      return NextResponse.json(
        { error: "未授权访问" },
        { status: 401 }
      )
    }

    const libraries = await prisma.eventLibrary.findMany({
      select: {
        id: true,
        name: true,
        description: true,
      }
    })

    return NextResponse.json(libraries)
  } catch (error) {
    return NextResponse.json(
      { error: "加载事件库失败" },
      { status: 500 }
    )
  }
} 